package com.xuecheng.content.fallback;

import com.xuecheng.content.feignclient.SearchServiceClient;
import com.xuecheng.content.model.po.CourseIndex;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Slf4j
@Component
public class SearchServiceClientFallback implements FallbackFactory<SearchServiceClient> {
    @Override
    public SearchServiceClient create(Throwable throwable) {
        return new SearchServiceClient() {
            @Override
            public Boolean add(CourseIndex courseIndex) {
                log.info("调用搜索服务添加课程索引时发生熔断，异常信息:{}",throwable.toString(),courseIndex);
                return null;
            }
        };
    }
}
